package com.example.springcloudactuator;

import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * </p>
 *
 * @author Zero
 * @since 2019/3/2
 */
@Configuration
@Endpoint(id = "example")
public class ExampleEndpoint {

    @ReadOperation
    public ResponseEntity<Map<String, Object>> read() {
        Map<String, Object> map = new HashMap<>();
        map.put("hello", "world");
        ResponseEntity entity = new ResponseEntity(map, HttpStatus.OK);
        return entity;
    }

    @WriteOperation
    public ResponseEntity<String> write() {
        ResponseEntity entity = new ResponseEntity("Write Operation", HttpStatus.OK);
        return entity;
    }

    @DeleteOperation
    public ResponseEntity<String> delete() {
        ResponseEntity entity = new ResponseEntity("Delete Operation", HttpStatus.OK);
        return entity;
    }

}
